﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using EricUtility.Windows.Forms;
using WatchSeriesHelper.Entities;
using TVOnline;
using TVOnline.VideoViewing;
using TVOnline.Windows.Forms;
using WatchSeriesHelper.Persistance;
using WatchSeriesHelper.Windows.Forms;

namespace WatchSeriesHelper.GUI
{
    public partial class MainForm : Form
    {
        private WatchSeriesTabContent main = new WatchSeriesTabContent();
        private TabPage MainTab { get { return tabControl1.TabPages[0]; } }
        public MainForm()
        {
            InitializeComponent();
        }

        private void MainForm_Load(object sender, EventArgs e)
        {
            TabControl old = tabControl1;
            Controls.Remove(old);
            CustomTabControl newone = new CustomTabControl();
            tabControl1 = newone;
            newone.Dock = old.Dock;
            newone.DisplayStyle = TabStyle.ChromeWithPinned;
            ImageList list = new ImageList();
            tabControl1.ImageList = list;
            list.Images.Add(WatchSeriesHelper.Properties.Resources.logo1);
            tabControl1.TabPages.Add(new FixedCustomizedTabPage(main));
            MainTab.ImageIndex = 0;
            MainTab.Text = "TV Shows";
            main.AskForANewTab+=new TabPageEventHandler(main_AskForANewTab);
            Controls.Add(newone);
            newone.TabClosing += new EventHandler<TabControlCancelEventArgs>(TabClosing);
        }

        void main_AskForANewTab(TabPage t)
        {
            tabControl1.TabPages.Add(t);
            tabControl1.SelectedTab = t;
        }

        void TabClosing(object sender, TabControlCancelEventArgs e)
        {
            if (e.TabPageIndex == 0)
                e.Cancel = true;
        }
    }
}
